#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@his-pc>
#
# Distributed under terms of the MIT license.

"""

"""


class ListNode(object):
    def __init__(self, val, next=None):
        self.val = val
        self.next = next


class Solution:
    def deleteDuplicates(self, head):
        # head不可能改变, 所以不需要dummy_head
        node = head

        while node and node.next:
            if node.val != node.next.val:
                node = node.next
                continue

            # 顺藤摸瓜: 顺着node.next直到不相等node.next
            may_same = node.next.next
            while may_same:
                if may_same.val != node.val:
                    break
                may_same = may_same.next
            node.next = may_same
            node = node.next

        return head


def main():
    print("start main")

if __name__ == "__main__":
    main()
